GBML manual / Collision

mask_h

The height of this instance’s collision box, in pixels - ANY height, including taller than the art. 0 (the default) means auto: take the height from `mask_sprite` if one is set, else from `sprite`, else 0.

Syntax

mask_h: int

Description

How tall this instance's collision box is, in pixels. Any height, independent of the art and of mask_w.

0, the default, means auto: take the height from mask_sprite if one is set, otherwise from sprite, otherwise 0.

Example

mask_h = 10;
mask_y = 11;

A tall character - 32 pixels of sprite - that collides only on its feet: a 10-pixel-tall box pushed 11 pixels down from the middle. The width is left on auto, so it still matches whatever the character is drawn as.

Auto is decided per axis

The two sizes are resolved separately, which is more useful than it sounds. mask_w = 18; on its own pins the width and leaves the height following the sprite; the reverse works too.

That means an object can say the one thing it actually cares about - "however wide I am drawn, I am only ten pixels tall to walk into" - without having to restate the other axis and keep it in step by hand.

A box is not a silhouette

Collision on this console is rectangles, always. A tall thin box and a short wide box are the two halves of describing a shape, and there is no third setting that makes the box follow the drawing.

If a single rectangle genuinely cannot describe an object, the usual answer is more than one instance: a boss with a vulnerable head and a solid body is two objects that move together, each with its own honest rectangle, not one object wishing for a better mask.

On the GBA

Auto is decided per axis, so `mask_w = 18;` on its own pins the width and leaves the height following the sprite. Setting either back to 0 (or to anything negative) puts that axis back on auto - which is exactly what an editor’s "auto-size" button writes, rather than writing today’s numbers in: an auto axis keeps following `sprite` when a project swaps it, a pinned one does not.

See also: mask_wmask_xmask_ymask_spritebox_topcollides